using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using eYap.sources.Net;
using agsXMPP.protocol.component;
using agsXMPP.protocol.client;

namespace eYap.src.Forms
{
    public partial class ChatControl : UserControl
    {
        public Contact contact;

        public ChatControl()
        {
            InitializeComponent();
        }

        public void GetContactReference(Contact contact)
        {
            this.contact = contact;
            lbl_Name.Text = contact.Name;
            pBox_Profile.Image = contact.photo;
            lbl_Status.Text = "You are chatting with " + contact.Name;
        }

        public void SetContactAvailability(int availability)
        {
            if (availability == 1)
                lbl_Status.Text = contact.Name + " is available";
            else if (availability == 2)
                lbl_Status.Text = contact.Name + " is away";
            else if (availability == 0)
                lbl_Status.Text = contact.Name + " is offline";
        }

        public void PrintRecievedMessage(string message)
        {
            rtbox_chat.Text += this.contact.Name + ": " + message + "\n";
        }

        public void SetChatStatus(int status)
        {
            if (status == 1)
                lbl_Status.Text = contact.Name + " has sent a message";
            else if (status == 2)
                lbl_Status.Text = contact.Name + " is typing a message.....";
            else if (status == 3)
                lbl_Status.Text = "";
        }

        private void tbox_chatbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                rtbox_chat.Text += contact.mainForm.fbclient.myInfo.Name + ": " + tbox_chatbox.Text + "\n";
                contact.mainForm.fbclient.xmppClient.Send(new agsXMPP.protocol.component.Message(contact.jid, MessageType.chat,
                                                                             tbox_chatbox.Text));
                tbox_chatbox.Clear();
            }
        }

        private void S(object sender, EventArgs e)
        {

        }

        private void lbl_Status_Click(object sender, EventArgs e)
        {

        }


    }
}
